package com.zs.hydrant.mapper;

import com.zs.hydrant.entity.Feedback;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

@Mapper
public interface FeedbackMapper {

    @Insert("INSERT INTO feedback (user_id, hydrant_id, feedback_type, content, photo, is_urgent, feedback_status, create_time) " +
            "VALUES (#{userId}, #{hydrantId}, #{feedbackType}, #{content}, #{photo}, #{isUrgent}, 0, NOW())")
    int addFeedback(Feedback feedback);

    @Select("SELECT * FROM feedback WHERE feedback_status = #{status} ORDER BY create_time DESC")
    List<Feedback> getByStatus(@Param("status") Integer status);

    @Update("UPDATE feedback SET feedback_status = #{status} WHERE id = #{id}")
    void updateStatus(@Param("id") Integer feedbackId, @Param("status") Integer status);
}